/*
 * @Autor: dingxiaolin
 * @Date: 2021-06-02 13:12:45
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-06-11 08:41:24
 */
import http from '@/utils/http/axios'
import { type } from './interface'

/**
 * @description: 根据code获取app菜单
 */
export function appMenus(params) {
    return http.request<type.MenuItem[]>({
        url: '/app-admin/menu/change',
        method: 'POST',
        params
    })
}

/**
 * @description: 获取系统菜单树，用于给角色授权时选择
 */
 export function SysMenuTreeForGrant (params) {
    return http.request<any>({
      url: '/app-admin/menu/treeForGrant',
      method: 'get',
      params
    })
  }

/**
 * @description: 获取菜单列表
 */
export function SysMenuList (params) {
  return http.request<any>({
    url: '/app-admin/menu/list',
    method: 'get',
    params
  })
}

/**
 * @description: 获取系统菜单树，用于新增，编辑时选择上级节点
 */
export function getMenuTree (params) {
  return http.request<any>({
    url: '/app-admin/menu/tree?application=' + params.application,
    method: 'get',
    params
  })
}

/**
 * @description: 增加菜单
 */
export function sysMenuAdd(params) {
  return http.request<type.MenuItem[]>({
      url: '/app-admin/menu/add',
      method: 'POST',
      params
  })
}

/**
 * @description: 编辑菜单
 */
export function sysMenuEdit(params) {
  return http.request<type.MenuItem[]>({
      url: '/app-admin/menu/edit',
      method: 'POST',
      params
  })
}

/**
 * @description: 删除菜单
 */
export function sysMenuDelete(params) {
  return http.request<type.MenuItem[]>({
      url: '/app-admin/menu/delete',
      method: 'POST',
      params
  })
}

/**
 * @description: 查看菜单详情
 */
export function sysMenuDetail(params) {
  return http.request<type.MenuItem[]>({
      url: '/app-admin/menu/detail?id=' + params.id,
      method: 'POST',
      params
  })
}
